package com.pan.controller.LogAndRegisController;

import com.pan.controller.tools.R1;
import com.pan.domain.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkadmin")
@Tag(name = "CheckAdminController",description = "检查登陆类型")
public class CheckAdminController {

    @Operation(summary = "检查登录类型",description = "检查登录的用户是否为超管")
    @GetMapping
    public R1 check(HttpServletRequest request){
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        if (user.getIsadmin()==1){
            return new R1(true,"超管登录");
        }else {
            return new R1(false,"用户登录");
        }
    }

}
